import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Frm extends JFrame implements ActionListener{

    /**
     * @param args
     */
    private JButton jb;
    public Frm()
    {
        this.setSize(300, 200);
        this.setLocation(300, 400);
        jb=new JButton("按钮");
        this.add(jb);
        jb.addActionListener(this);//鍔犲叆浜嬩欢鐩戝惉
        this.setVisible(true);
        
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
           Frm frame=new Frm();
           
    }
   
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        if(e.getSource()==jb)
        {
            this.dispose();
            new JTextArea();
        }
    }

}
class JTextArea extends JFrame{

    /**
     * @param args
     */
    public JTextArea()
    {
        
        this.setSize(300, 200);
        this.setLocation(300, 400);

this.setVisible(true);
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         JTextArea frame=new JTextArea();
    }

}






